#include<stdio.h>
int main() {
	int n = 0;
	int m = 0;
	int i = 0;
	//输入
	scanf("%d%d", &n, &m);
	int arr[n];
	int arr1[m];
	for (i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &arr1[i]);
	}
	//排序
	//1.先合并再排序
	//(1)合并
	int arr2[n + m];
	for (i = 0; i < n; i++) {
		arr2[i] = arr[i];
	}
	for (i = n; i < m + n; i++) {
		arr2[i] = arr1[i - n];
	}
	//(2)排序
	int j = 0;
	int change = 0;
	for (i = 0; i < n + m; i++) {
		for (j = i; j < n + m; j++) {
			if (arr2[j] > arr2[j + 1]) {
				int temp = arr2[j];
				arr2[j] = arr2[j + 1];
				arr2[j + 1] = temp;
				change++;
			}
		}
		if (!change) {
			break;
		}
	}
	//打印
	for (i = 0; i < m + n; i++) {
		printf("%d ", arr2[i]);
	}
	return 0;
}
